<?php
/**
 * login controller
 * @package app-member_controller
 */
load_controller('/memberbase');
/**
 * login controller
 * @author pandajingjing
 * @package app-member_controller
 */
class logincontroller extends memberbasecontroller{

	function doRequest(){
		$arrErrInfo=array();
		$strAction=$this->getParam('hidAction','post');
		if('login'==$strAction){
			$strLoginValue=$this->getParam('txtLoginValue','post');
			$strUserPwd=$this->getParam('pwdUserPwd','post');
			load_lib('/bll/member/login');
			$clsLogin=new bll_member_login();
			$arrUserInfo=array();
			$mixResult=$clsLogin->loginUser($strLoginValue,$strUserPwd,$this->getClientIP(),$this->getTime(),$arrUserInfo);
			if(is_array($mixResult)){
				$arrErrInfo=$mixResult;
			}else{
				$this->setCookie('mauthcode',$clsLogin->encryptLoginInfo(array(
						'USERID'=>$arrUserInfo['USERID'],
						'USERNAME'=>$arrUserInfo['USERNAME']
				)),31536000);
				load_controller('/panel');
				$this->redirectURL(panelcontroller::getURL());
			}
		}else{
			$this->setViewState('frmLogin','txtLoginValue','');
			$this->setViewState('frmLogin','hidAction','login');
		}
		load_controller('/reg');
		$this->setData('strRegURL',regcontroller::getURL());
		$this->setData('arrErrInfo',$arrErrInfo);
		return '/login';
	}

	/**
	 * 获取访问该控制器的路径
	 */
	static function getURL($p_strAction='',$p_arrParam=array(),$p_bolSecure=false,$p_strPre='/login'){
		return parent::getURL('/login',$p_strAction,$p_arrParam);
	}
}